<%-- 
    Document   : shoppingcart
    Created on : Sep 20, 2011, 7:34:12 AM
    Author     : Red Army
--%>

<%@page import="org.netbeans.xml.schema.accountschema.Users.User"%>
<%@page import="javax.xml.transform.stream.StreamResult"%>
<%@page import="java.io.StringWriter"%>
<%@page import="javax.xml.transform.stream.StreamSource"%>
<%@page import="javax.xml.transform.Transformer"%>
<%@page import="java.io.File"%>
<%@page import="javax.xml.transform.TransformerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="pageFunc"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Your shopping cart</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<link rel="stylesheet" type="text/css" href="css/menu.css"/>
<link rel="stylesheet" type="text/css" href="css/button.css"/>
</head>
<%
                    User user = (User) session.getAttribute("USER");
%>
<body>
    <div id="container">
    	<div id="header">
        	<div id="logo">
            	<img src="images/logo_top.gif" width="500" height="62" alt="logo" />
            </div>
            <!-- ######################### User Login Module ######################## -->
                <pageFunc:set var="user" value="${sessionScope.USER}"/>
                <pageFunc:if test="${empty user}">
                    <form action="UserController" method="POST">
                        <div id="login">
                            <br/><span class="loginText">Username</span>
                            <input id="txtUsername" onclick="SelectText('txtUsername')" name="txtUsername" type="text" maxlength="20" width="100px"/>
                            <br/><span class="loginText">Password</span>
                            <input id="txtPassword" onclick="SelectText('txtPassword')" name="txtPassword" type="password" maxlength="20" width="100px"/>
                            <br/>
                            <input type="submit" class="inputBtn" value="Login" name="btnAction" />
                            <input type="submit" value="Forgot Password ?" name="btnAction" />
                            <input type="button" value="Register" name="btnAction" onclick="location.href='user.jsp'"/>
                        </div>
                    </form>
                </pageFunc:if>   
                <pageFunc:if test="${not empty user}">                    

                    <pageFunc:url var="editUser" value="UserController">
                        <pageFunc:param name="btnAction" value="AccountSetting"/>
                    </pageFunc:url>
                    <br/><span class="loginText">
                        <a class="linkLoginText" style="width:40px;" href="${editUser}">Welcome! ${user.getID()}</a>
                    </span>

                    <pageFunc:url var="logout" value="UserController">
                        <pageFunc:param name="btnAction" value="Log Out"/>
                    </pageFunc:url>
                    <a class="linkLoginText" style="width:40px;" href="${logout}">Log Out</a>
                </pageFunc:if>
            </div>
            <!-- *************************** End User Login Module ********************************* -->
    	</div>
        <div id="banner">
       	  <img src="images/banner2.jpg" name="bannerImg" width="760" height="210" id="bannerImg" />
        </div>
		<div id="menu">
        	<ul class="navigation">
                <li><a href="index.jsp"><em class="home"></em><b>Home</b></a></li>
                <li><a href="news.jsp"><em class="templates"></em><b>News</b></a></li>
                <li><a href="user.jsp"><em class="psd"></em><b>User</b></a></li>
                <li><a href="catalogue.jsp"><em class="tutorials"></em><b>Catalogue</b></a></li>
                <li class="current"><a href="shoppingcart.jsp"><em class="shop"></em><b>Shopping cart</b></a></li>
                <li><a href="contact.html"><em class="contact"></em><b>Contact Us</b></a></li>
            </ul>
      	</div>
      
        <div id="main">
        	<span class="searchText" style="width:100%;color:yellow">YOUR SHOPPING CART</span><br/><br/>
        	<table width="100%" border="1">
              <tr>
                <th scope="col">Image</th>
                <th scope="col">Description</th>
                <th scope="col">Price</th>
                <th scope="col">Quality</th>
<!--                <th scope="col">Total</th> -->
                <th scope="col"></th>
              </tr>
<%
                    TransformerFactory tf = TransformerFactory.newInstance();
                    StreamSource xsltFile = new StreamSource(new File(getServletContext().getRealPath("WEB-INF/shoppingcart.xsl")));
                    Transformer trans = tf.newTransformer(xsltFile);
                    StreamSource xmlFile = new StreamSource(new File(getServletContext().getRealPath("WEB-INF/" + session.getId() + "_shoppingCart.xml")));
                    String htmlContent = "";
                    StringWriter html = new StringWriter();
                    StreamResult rs = new StreamResult(html);

                    trans.transform(xmlFile, rs);

                    out.print(html.toString());
%>
            </table>
            <div style="float:right;padding:30px;">
                <form action="checkOut">
                <button class="rounded"><span>Purchase</span></button>
                </form>
                <button class="rounded"><span>Remove all item</span></button>
            </div>
        </div>
        <div id="footer" class="navigation">
            <span style="margin-top:10px">Copyright by LocHT. All right reserved.</span>
        </div>
    </div>
</body>
</html>